package utils;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class CloseUtil {

	public static void closeSocket(Socket socket) {
		try {
			socket.close();
		} catch (IOException e) {
			System.out.println("ERROR: Socket close error............");
			e.printStackTrace();
		}
	}
	
	public static void closeInputStream( InputStream in ) {
		
		try {
			if (null != in) {
				in.close();
			}
		} catch (IOException e) {
			System.out.println("ERROR: InputStream close error............");
			e.printStackTrace();
		}
	}
	
	public static void closeOutStream( OutputStream out ) {
		
		try {
			if (null != out) {
				out.flush();
				out.close();
			}
		} catch (IOException e) {
			System.out.println("ERROR: InputStream close error............");
			e.printStackTrace();
		}
	}
	
	public static void closeServerSocket(ServerSocket serverSocket) {
		try {
			serverSocket.close();
		} catch (IOException e) {
			System.out.println("ERROR: ServerSocket close error............");
			e.printStackTrace();
		}
	}
}
